﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:personalplaner.common.controls">

    <!-- 
    *****************************************************************
    Brushes for common styles 
    *****************************************************************
    -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/personalplaner.common;component/resources/CommonBrushes.xaml"/>
        <ResourceDictionary Source="/personalplaner.common;component/resources/CommonStyles.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style BasedOn="{StaticResource BoarderedButtonStyle}" TargetType="Button" x:Key="ButtonStyle">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="Goldenrod"/>
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="BorderBrush" Value="Goldenrod"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <!-- 
    *****************************************************************
    Template for ClosableTabItemHeader
    *****************************************************************
    -->
    <Style TargetType="{x:Type local:CollapsibleGroupBox}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="BorderBrush" Value="Gray"/>
        <Setter Property="BorderThickness" Value="1,0,1,1"/>
        <Setter Property="Padding" Value="10,5,10,10"/>
        <Setter Property="Margin" Value="1"/>
        <Setter Property="HeaderBackground">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="WhiteSmoke" Offset="0"/>
                        <GradientStop Color="LightGray" Offset="1"/>
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type  local:CollapsibleGroupBox}" >
                    <Grid Margin="{TemplateBinding Margin}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="22"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <Border BorderBrush="{TemplateBinding BorderBrush}" Focusable="False" BorderThickness="{TemplateBinding HeaderBorderThickness}" SnapsToDevicePixels="True" Grid.Column="0" Grid.ColumnSpan="2" CornerRadius="{TemplateBinding HeaderCornerRadius}" Background="{TemplateBinding HeaderBackground}"/>

                            <Border Name="ButtonBorder" BorderBrush="Transparent" Background="Transparent" BorderThickness="0" Width="20">
                                <Button x:Name="PART_PinCollapse" VerticalAlignment="Center" Focusable="True" Width="10" Height="10" Style="{StaticResource ButtonStyle}" Margin="0,0,0,0" >
                                    <Path Name="CollapsPin" Data="M 1 4 L 7 4" Stroke="Black" StrokeThickness="1"/>
                                </Button>
                            </Border>

                            <ContentControl Foreground="{TemplateBinding Foreground}" Focusable="False" FontSize="12" FontWeight="Bold" Margin="4,2,0,0" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top">
                                <ContentPresenter
                                    ContentSource="Title"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Top"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </ContentControl>
                        </Grid>


                        <Border Grid.Row="1" BorderBrush="{TemplateBinding BorderBrush}" Focusable="False" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" CornerRadius="{TemplateBinding CornerRadius}">
                            <Grid Name="ContentHolder" Margin="{TemplateBinding Padding}" MinHeight="0" >
                                <Grid.LayoutTransform>
                                    <ScaleTransform/>
                                </Grid.LayoutTransform>
                                
                                <ContentPresenter x:Name="PART_Content" LayoutTransform="{x:Null}"/>
                            </Grid>
                        </Border>

                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property ="IsCollapsed" Value="true">
                            <!--<Setter Property="Visibility" Value="Collapsed" TargetName="PART_Content"/>-->
                            <Setter Property="Data" Value="M 1 4 L 7 4 M 4 1 L 4 7" TargetName="CollapsPin"/>
                            <Trigger.EnterActions>
                                <BeginStoryboard x:Name="scaleAnimation">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ContentHolder" Storyboard.TargetProperty="LayoutTransform.ScaleY" Duration="0:0:0.25" DecelerationRatio="1" To="0" />
                                        <DoubleAnimation Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity" Duration="0" BeginTime="0" To="0"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:2" Value="{x:Static Visibility.Hidden}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="ContentHolder" Storyboard.TargetProperty="LayoutTransform.ScaleY" Duration="0:0:0.25" AccelerationRatio="1" To="1" />
                                        <DoubleAnimation Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity" Duration="0:0:0.1" BeginTime="0:0:0.25" To="1"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility" BeginTime="0:0:0.25">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            
                        </Trigger>
                        <Trigger Property="IsCollapseable" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonBorder"/><!--PART_PinCollapse-->
                        </Trigger>

                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>